perm filename EADD3.2[EAL,HE]1 blob sn#674838 filedate 1982-09-27 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	{$NOMAIN	Editor: aux routines for addStmnt }
C00004 00003	procedure addSetup(nextLinep: cursorpp var emptyp,stok,clok: boolean
C00008 ENDMK
C⊗;
{$NOMAIN	Editor: aux routines for addStmnt }

%include eedit.hdr;

{ Externally defined routines from elsewhere: }

	(* From EAUX1A *)
procedure clearLine(i: integer);				external;

	(* From EEXPED *)
function exprEditor(line,lstart,llength,estart: integer;
	var elength: integer; off: integer): ascii;		external;

	(* From EAUX2B *)
procedure lastStmnt(i: integer; downp: boolean);		external;

	(* From EAUX2C *)
procedure insertLines(start,number,coff: integer);		external;

	(* From ETOKEN *)
procedure eGetToken;						external;

	(* From EPUTST *)
procedure putstmnt(s: statementp; indent, plevel: integer);	external;

	(* From PP *)
procedure relLine(l: linerecp);					external;

procedure addSetup(nextLinep: cursorpp; var emptyp,stok,clok: boolean;
	var l,elen: integer; firstTime: boolean; var echar: ascii); external;
procedure addSetup;
 begin
 with cursorStack[cursor] do
  begin					(* figure out where we are *)
  nextLinep↑.ind := ind;		(* copy current cursor info *)
  nextLinep↑.stmntp := stmntp;
  nextLinep↑.st := st;			(* also copies nd pointer *)
  emptyp := false;			(* assume we need to add a new line *)
  if stmntp then emptyp := st↑.stype = emptytype; (* unless we can use current one *)
  end;
 if emptyp then
   begin
   l := cursorLine - topDline + 1;	(* offset into line array *)
   relLine(lines[l]);			(* release old empty line *)
   lines[l] := nil;
   clearLine(l-firstDline+1);		(* clear line *)
   clOk := false;			(* only accept a statement *)
   stOk := true;
   end
  else
   begin				(* need to insert a new line *)
   insertLines(cursorLine,1,1);
   if not nextLinep↑.stmntp then
     begin			(* if it isn't a statement neither are we *)
     with nextLinep↑ do
      stOk := (nd↑.ntype = procdefnode)	(* unless it's a procedure definition *)
	   or (nd↑.ntype = clistnode);	(* or a case label *)
     clOk := not stOk;
     end
    else
     begin			(* see if it's in a block, coblock or case *)
     with cursorStack[cursor-1] do
      if stmntp then
	stOk := (st↑.stype = blocktype) or (st↑.stype = coblocktype) or
		(st↑.stype = casetype)
       else stOk := (nd↑.ntype = clistnode) or (nd↑.ntype = colistnode);
     l := cursorLine;
     lastStmnt(1,true);	(* see if last statement can have clauses *)
     with cursorStack[cursor].st↑ do
      clOk := (movetype <= stype) and (stype <= centertype);
     cursorLine := l;
     setCursor := true;
     curLine := 0;
     firstLine := 0;
     lastLine := -1;
     putStmnt(dprog,0,99);		(* restore cursor stack *)
     setCursor := false;
     end
   end;
 if firstTime then
   begin				(* get insertion *)
   elen := 1;
   listing[1] := ' ';
   echar := exprEditor(cursorLine-topDline-firstDline+2,1,1,1,elen,0);
   end;
 flushcomments := false;		(* comments are ok here *)
 eGetToken;	(* figure out what we're inserting: statement, label, clause *)
 flushcomments := true;		(* don't allow comments anywhere else *)
 end;